package com.mapbased.cc.form;

import com.mapbased.wfw.RenderContext;
import java.io.IOException;
import com.mapbased.wfw.PageLoader;
import org.dom4j.Element;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: mapbased.com</p>
 *
 * @author chy_hs(Baily)
 * @version 1.0
 */
public class EditAreaFormElement
    extends FormElement
{

    protected void initCustom(Element e,PageLoader.LoadContext pl)
    {
        if(this.style == null)
        {
            this.style="";
        }
    }

    final protected String getType()
    {
        return "textarea";
    }

    /**
     * <div id="sss"></div>
                        <script language="JavaScript" type="text/javascript">
                        writeRichText('test', '@request{test}', "width:100%;height:500px;", true, false);
                        var _form =findForm('sss');
                        window.__rte1=_form.onsubmit;

                        _form.onsubmit=function()
                        {
                            updateRTE('test');
                            alert("update OK")
                            if(__rte1!=null)
                            {
                                __rte1();
                            }
                        }
                        </script>

     * @param rc RenderContext
     * @throws IOException
     */

    public void renderInputPart(RenderContext rc)
        throws IOException
    {
        java.io.Writer w=rc.getOutputWriter();
        w.write("<div id=\"div_");
        w.write(this.name);
        w.write(
            "\" ><script language=\"JavaScript\" type=\"text/javascript\">\n");
        w.write("writeRichText('");
        w.write(name);
        w.write("', '");
        w.write(rc.getSureSingleParam(this.name));
        w.write("','");
        w.write(this.style);
        w.write("' , true, false);\n ");
        w.write("var _form =findForm('div_");
        w.write(this.name);
        w.write("');window.__");
        w.write(this.name);
        w.write("=_form.onsubmit; _form.onsubmit=function(){updateRTE('");
        w.write(this.name);
        w.write("');if(__");
        w.write(this.name);
        w.write("!=null) __");
        w.write(this.name);
        w.write("();}</script></div>");

    }

}
